

function remove_note_cb (raw){
    fn_wrap(raw, 
        function (state, data) {
            sidebar.update_note_list();
            if (global.crr_note_id == data['id']){
                //console.log(global.crr_note_id+','+data['id'])
                //switch_page(0);
                global.crr_note_id = -1;
                global.crr_note_title = '';
            }
            notify('Remove notebook `' + data['title'] + '` done. You can not Undo yet.');
        },
        function (state, data) {
            notify('Remove notebook fail.');    
        }
    );
}


function remove_block_cb (raw){
    fn_wrap(raw, 
        function (state, data) {
            var id = data['id'];
            $('#' + id + '_block-item').parent().parent().parent().remove();
            notify('Remove note `' + data['content'] + '` done. You can not Undo yet.');
        },
        function (state, data) {
            notify('Remove block fail.');    
        }
    );
}

function update_block_tag_list_cb (raw){
    fn_wrap(raw,
        function (state, data) {
            var id = data['block_id'];
            var tags = data['tags'];
            $('#'+id+'_block-item').find('.block-item-tag').remove();
            var tag_bar = $('#'+id+'_block-item').find('.block-item-tag-bar');
            for (var i = 0; i < tags.length; i+=1) {
                tag_bar.append('<a class="block-item-tag" href="#" title="tagged by '
                    + tags[i].count + ' notes."'
                    +'>'+ tags[i].name +'</a></span>');
            }
        },
        function (state, data) {
            notify('Load block tags fail.');    
        }
    );
}

function save_block_tag_cb(raw) {
    fn_wrap(raw,
        function (state, data) {
            update_block_tag_list_do(data.block_id);
        },
        function (state, data) {
            notify('Save block tags fail.');    
        }
    );
}

